function getJson() {
    $.get("http://192.168.109.29:8080/207Shared/GetCurrent", function (data, status) {

        if (status == "success") {
            var obj,
                student_html = "",
                report_html = "",
                $student = $("#student"),
                $container = $('#report-content');

            num = 0;
            $student.empty();
            obj = JSON.parse(data);
            console.log(data);
            $.each(obj, function (index, comment) {
                // generate the left list

                $("#student li a").each(function () {
                    // console.log($(this).text().slice(1, -1));
                    // console.log(comment['name']);
                    if (comment['name'] == $(this).text().slice(1, -1)) {
                        console.log('run');
                        $(this).children('span').html(parseInt($(this).children('span').text()) + 1);
                    }
                })

                student_html = '<a href="#section-' + (num + 1) + ' "> ' + comment['name'] + '<span class="badge pull-right">1</span></span></a>'

                // generate the right part
                report_html = '<div class="page-header"><h2>' + comment['name'] + '第XX周周报 <small>' + comment['subject'] + '</small></h2></div><h3>本周工作总结</h3>'
                    + formatList(comment['summary'])
                    + '<h3>本周存在问题</h3>'
                    + formatList(comment['problem'])
                    + '<h3>下周工作计划</h3>'
                    + formatList(comment['goal']);


                var $li = $("<li></li>");
                $li.html(student_html);
                $student.append($li);

                var $div_report = $("<section></section>");
                $div_report.attr('id', 'section-' + (num + 1))
                $div_report.html(report_html);
                $container.append($div_report);

                num = index + 1;

            });


            // console.log("数据：" + data + "\n状态：" + status);
        }
        else {
            alert("stat us: " + status);
        }

    })
}
getJson();

function formatList(list) {
    var num = 1,
        html = "";
    for (i in list) {
        html += '<p>' + num + '.' + list[i] + '</p>';
        num += 1;
    }
    return html;
}
